package Day04;
import java.util.Scanner;
public class GuessNum {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = 0;
		//生成随机数
		int ranNum = (int)(Math.random() * 1000);
//		while(num != ranNum) {
//			System.out.print("请输入你猜测的数字(1-1000),退出请按0:");
//			num = scan.nextInt();
//			if(num == ranNum) {
//				System.out.println("猜对了");
//				break;
//			}else if(num > ranNum) {
//				System.out.println("太大了");
//			}else if(num < ranNum && num != 0)
//				System.out.println("太小了");
//			}else {
//				System.out.println("已退出");
//				break;
//			}
//		}
		do {
			System.out.print("请输入你猜测的数字(1-1000),退出请按0:");
			num = scan.nextInt();
			if(num == 0) {
				System.out.println("已退出");
				return;
			}else if(num > ranNum) {
				System.out.println("太大了");
			}else if(num < ranNum){
				System.out.println("太小了");
			}else {
				System.out.println("输入有误，请输入数字");
			}
		}while(num != ranNum);
		System.out.println("恭喜你猜对了");
		scan.close();
	}

}
